<meta name="csrf-token" content="{{ csrf_token() }}">
<script src="{{URL::asset('js/echarts.js')}}"></script>
<script src="{{URL::asset('js/customed.js')}}"></script>
<script src="{{URL::asset('js/jspdf.min.js')}}"></script>
<script src="{{URL::asset('js/html2canvas.js')}}"></script>
<script src="{{URL::asset('js/jquery.js')}}"></script>
<div id="page-wrapper">
    <div class="box box-body" id="chart_container" style="width:210mm;padding:0 !important;margin: 0 auto;">
		<div style="width:210mm;height:297mm;background:url(/upload/kly/ScienceFestiva_B_0.png) no-repeat;background-size:210mm 297mm;margin:0;padding:0;position:relative;">
			<span id="ch_name" style="font-size: 7mm;position: absolute;top: 100mm;left: 40mm;font-famliy:'黑体'"></span>
			<span id="en_name" style="font-size: 7mm;position: absolute;top: 116.5mm;left: 40mm;font-famliy:'黑体'"></span>
			<span class="camp_sn" style="font-size: 7mm;position: absolute;top: 133mm;left: 40mm;font-famliy:'黑体'"></span>
			<span id="tutor_name" style="font-size: 7mm;position: absolute;top: 149.5mm;left: 40mm;font-famliy:'黑体'"></span>
		</div>
		<div style="width:210mm;height:297mm;background:url(/upload/kly/ScienceFestiva_B_1.png) no-repeat;background-size:210mm 297mm;margin:0;padding:0;position:relative;">
			<div style="width: 188mm;height:244mm;background: #FFF;position: absolute;top:43mm;left:11mm;"></div>
			<!-- <div id="radar" style="width: 80mm;height: 70mm;position: absolute;top: 46mm;left: 14mm;"></div> -->
			<div id="diy0" style="width: 182mm;height: 90mm;position: absolute;top:45mm;left: 14mm;"></div><!-- 阅读速率 -->
			<div id="diy1" style="width: 182mm;height: 90mm;position: absolute;top: 135mm;left: 14mm;"><!-- 阅读正确率 --></div>
			<!--<div id="diy2" style="width: 182mm;height: 60mm;position: absolute;top: 213mm;left: 14mm;"></div>--><!-- 信息 -->
			<!-- <textarea id="radar-border" style="width: 94mm;height: 61mm;position: absolute;top: 46mm;left: 99mm;font-size:4mm;resize: none;background:none;border:none;outline:none;padding:3mm;"></textarea> -->

			<!-- <textarea id="diy0-border" style="width: 104mm;height: 36mm;position: absolute;top: 133mm;left: 89mm;font-size:4mm;resize: none;border:none;outline:none;padding:3mm;background:none;"></textarea> -->
			<div style="width: 182mm;height: 65mm;background: #dceff6;position: absolute;border-radius: 3mm;top: 219mm;left: 14mm;">
				<div id="diy1-text" style="margin:3mm;margin-bottom:0;width: 176mm;height: 59mm;font-size:4mm;">哇哦～18天的学习就像一段冒险之旅，为你三周的勇往直前点赞，Science Festiva看到了你的改变和成长。从第一周到第三周，绘本boss越来越难打👺，但是你并没有缴械投降，反而越战越勇，攻势一周比一周猛，成绩也一周比一周好，在自然拼读的修炼之路上，恭喜你点亮了“三寸不烂之舌👅”新技能，能够快速拼读出陌生的单词，希望你以后持续精进，不断给自己添加新的技能✅，相信你一定能在往后的更加刺激和精彩的英语学习之旅中披襟斩棘，大获全胜️！</div>
				<!-- <textarea id="diy1-border" style="width: 100%;height: 20mm;font-size:4mm;resize: none;border:none;outline:none;padding:0 3mm;background:none;"></textarea> -->

			</div>
			<!--<div style="width: 182mm;height: 20mm;background: #dceff6;position: absolute;border-radius: 3mm;top: 265mm;left: 14mm;"> -->
				<!-- <div id="diy2-text" style="margin:3mm;margin-bottom:0;width: 176mm;height: 20mm;font-size:4mm;"></div> -->
				<!-- <textarea id="diy2-border" style="width: 100%;height: 36mm;font-size:4mm;resize: none;border:none;outline:none;padding:3mm;background:none;"></textarea> -->
			<!--</div>-->
		</div>
		<div style="width:210mm;height:297mm;background:url(/upload/kly/ScienceFestiva_B_1.png) no-repeat;background-size:210mm 297mm;margin:0;padding:0;position:relative;">
			<div style="width: 188mm;height:244mm;background: #FFF;position: absolute;top:43mm;left:11mm;"></div>
			<h3 style="text-align:center;width:100%;position:absolute;top:31mm;">
				<span class="camp_sn"></span>阅读正确词数情况
			</h3>
			<div id="last0" style="width:182mm;height:60mm;position:absolute;top: 40mm;left:14mm;"></div>
			<h3 style="text-align:center;width:100%;position:absolute;top:94mm;">
				个人落实度情况
			</h3>
			<div id="kq-chart" style="width: 182mm;height: 60mm;position: absolute;top: 110mm;left: 14mm;"></div>
			<!-- <div id="kq-text" style="text-align: center;width: 175mm;height: 23mm;position: absolute;top: 112mm;left: 19mm;font-size:4mm;padding:3mm;"></div> -->
			<!-- <textarea id="kq-border" style="width: 175mm;height: 28mm;position: absolute;top: 135mm;left: 19mm;font-size:4mm;resize: none;border:none;outline:none;padding:2mm;background: none"></textarea> -->
			<!-- <div style="width:180mm;height:30mm;position:absolute;top:134mm;left:18mm;background:#FFF;"></div> -->
			<div id="zy-chart0" style="width: 182mm;height: 60mm;position: absolute;top: 165mm;left:14mm"></div>
			<!-- <div id="zy-chart1" style="width: 96mm;height: 64mm;position: absolute;top: 166mm;left: 105mm;"></div> -->
			<!-- <div id="zy-text" style="text-align: center;width: 175mm;height: 23mm;position: absolute;top: 200mm;left: 19mm;font-size:4mm;padding:3mm;"></div> -->
			<div id="zy1-border" style="width: 176mm;height: 57mm;position: absolute;top: 224mm;left: 18mm;font-size:4mm;resize: none;border:none;outline:none;background: #dceff6;border-radius: 3mm;"></div>
			<textarea id="zy-border" style="width: 171mm;height: 54mm;position: absolute;top: 224mm;left: 18mm;font-size:4mm;resize: none;border:none;outline:none;padding:3mm; background: none;border-radius: 3mm;">恭喜你圆满完成2019年苦令营的学习~
首先，你打败了自己的起床气和小惰性，选择面对每一天的新挑战！为你的坚持点赞！
对于你来说，每天上课时最开心的，回家复习是最痛苦的！但最终，让你头大的视频作业和音频作业，你都也一次不落的完成了~
相信准时参与课堂，按质完成复习的好习惯一定可以为你的学习之路奠定一个坚实的基础！加油吧，少年！</textarea>
			<!-- <div id="last1" style="width:182mm;height:60mm;position:absolute;top: 108mm;left:14mm;"></div>
			<div id="last2" style="width:182mm;height:60mm;position:absolute;top: 175mm;left:14mm;"></div>
			<div style="width: 182mm;height: 43mm;background: #dceff6;position: absolute;border-radius: 3mm;top: 240mm;left: 14mm;">
				<div style="width:176mm;height: 37mm;margin: 3mm;">123456</div>
			</div> -->
		</div>
    </div>
    <div style="text-align: center;margin-top: 10mm;margin-bottom: 10mm;">
        <button id="btn_save" class="btn btn-success" style="width: 50mm;height: 20mm;font-size: larger;font-weight: bolder" onclick="save_memo()">保存评语</button>
        <button id="btn_pdf" class="btn btn-danger" style="width: 50mm;height: 20mm;font-size: larger;font-weight: bolder" onclick="o_window(false)">保存为PDF</button>
		<button id="btn_pdf" class="btn btn-primary" style="width: 50mm;height: 20mm;font-size: larger;font-weight: bolder" onclick="o_window(true)">print</button>
    </div>
</div>
<script>
var stFullName;
$(function() {
    var param = {
    	_token:"{{csrf_token()}}",
    	id:window.location.href.split('=')[2]
    };
	$.post('/admin/kly_report_get',param,function(res){
		stFullName = res.student["{{$id}}"].ch_name + "-" + res.student["{{$id}}"].en_name;
		drawChart(res);
		drawLastChart(res.camp_name);
		fillText(res);
		setTimeout(function() {
			o_window(false);
		},2);
    });
})

function drawLastChart(camp) {
	camp = Number(camp.split("营")[1]);
	var nameList = ["阅读正确单词书","15秒正确阅读的字母数","1分钟正确拼读的单词数"];
	var data = [
		[],[],[],[],[],[],[],[],[],
		// 10 a:小 b:大
		[{
			"a":[34.00,90.64,97.98,107.17],"b":[53.44,102.26,112.30,115.80] // 阅读
		},{
			"a":[12.76,8.85,13.91,17.59],"b":[14.45,9.98,23.19,17.91] // 字母
		},{
			"a":[5.20,18.82,20.98,19.89],"b":[8.22,23.19,15.41,19.09] // 自然
		}],
		// 11
		[{
			"a":[63.82,125.50,124.71,129.00],"b":[53.44,102.26,112.30,115.80] // 阅读
		},{
			"a":[16.34,10.79,16.64,19.23],"b":[14.45,9.98,23.19,17.91] // 字母
		},{
			"a":[11.66,23.66,25.11,18.45],"b":[8.22,23.19,15.41,19.09] // 自然
		}],
		// 12
		[{
			"a":[56.56,87.81,177.44,114.11],"b":[53.44,102.26,112.30,115.80] // 阅读
		},{
			"a":[14.84,9.16,13.66,17.37],"b":[14.45,9.98,23.19,17.91] // 字母
		},{
			"a":[7.35,20.47,22.49,17.59],"b":[8.22,23.19,15.41,19.09] // 自然
		}],
		// 13
		[{
			"a":[57.98,106.91,108.56,112.47],"b":[53.44,102.26,112.30,115.80] // 阅读
		},{
			"a":[13.93,11.16,17.55,18.21],"b":[14.45,9.98,23.19,17.91] // 字母
		},{
			"a":[8.57,22.56,24.17,19.68],"b":[8.22,23.19,15.41,19.09] // 自然
		}],
	];
	var dataList = data[camp-1];
	for(let i=0;i<1;i++){
		var opt = {
			title: {
				text: nameList[i],
				textStyle:{color:"#9C9EA0",fontSize:16},
			},
			animation: false,
			tooltip: {trigger: 'axis'},
			legend: {
				data:['小营平均','大营平均'],
				top:"10%",
				textStyle:{color:"#9C9EA0"},
			},
			color:["#DCD235","#1E4098","#2CA6E0"],
			xAxis: {
				type: 'category',
				boundaryGap: true,
				data:["营前","第1次","第2次","第3次"],
				axisLine: {
					lineStyle: {type: 'solid',color: "#9C9EA0"}
				},
				axisLabel: {
					textStyle: {color: "#9C9EA0"},
					fontSize:16
				}
			},
			yAxis: {
				type: 'value',
				scale:false,
				axisLine: {
					lineStyle: {type: 'solid',color: "#9C9EA0"}
				},
				axisLabel: {
					textStyle: {color: "#9C9EA0"},
					fontSize:16
				},
				splitLine:{
					lineStyle:{color:"#F2F2F3"}
				}
			},
			series: [{
				name:'小营平均',
				type:'line',
				data:dataList[i]["a"],
				itemStyle : { normal: {label : {show: true},textStyle:{color:"#9C9EA0"}}},
				lineStyle : {normal:{width:3}}
			},{
				name:'大营平均',
				type:'line',
				data:dataList[i]["b"],
				itemStyle : { normal: {label : {show: true},textStyle:{color:"#9C9EA0"}}},
				lineStyle : {normal:{width:3}}
			}]
		}
		echarts.init(document.getElementById("last"+i)).setOption(opt);
	}
}

function drawChart(e) {
	var item = [];
	for(i in e.item){
		if(e.item[i].type == "2"){
			item.push(e.item[i].item)
		}
	}
	for(i in item) {
		// if(item[i] == "phonics_rate"){
		// 	var idName = "diy2";
        //     var name = "1分钟正确拼读的单词数";
		// }else if(item[i] == "letter_rate"){
		// 	var idName = "diy1";
		// 	var name = "15秒正确阅读的字母数";
		// }else if(item[i] == "reading_rate"){
		// 	var idName = "diy0";
		// 	var name = "阅读正确单词数";
		// }else{
		// 	continue;
		// }
		if(item[i] == "phonics_rate" || item[i] == "letter_rate"){
			var idName = "diy1";
            var name = "个人自然拼读统测测试成绩";
			var opt = {
				title: {
					text: name,
					textStyle:{color:e.color.text,fontSize:16},
				},
				animation: false,
				tooltip: {
					trigger: 'axis'
				},
				legend: {
					data:['个人自然拼读统测测试成绩','小营平均'],
					top:"10%",
					textStyle:{color:e.color.text},
				},
				color:e.color.image,
				xAxis: {
					type: 'category',
					boundaryGap: false,
					data:["营前","营后"],
					axisLine: {
						lineStyle: {type: 'solid',color: e.color.axis}
					},
					axisLabel: {
						textStyle: {
							color: e.color.text,fontSize:16}
					}
				},
				yAxis: {
					type: 'value',
					scale:true,
					axisLine: {
						lineStyle: {type: 'solid',color: e.color.axis}
					},
					axisLabel: {
						textStyle: {
							color: e.color.text,fontSize:16}
					},
					splitLine:{
						lineStyle:{color:e.color.split}
					}
				},
				series: [{
					name:'个人自然拼读统测测试成绩',
					type:'line',
					data:data_person(e),
					// data:[e.student["{{$id}}"][item[i]].all[1],e.student["{{$id}}"][item[i]].all[4]],
					itemStyle : { normal: {label : {show: true},textStyle:{color:e.color.text}}},
					lineStyle : {normal:{width:3}}
				},{
					name:'小营平均',
					type:'line',
					data:data_sm_camp(e),
					// data:[e.common['small_'+item[i]+'_score'][1],e.common['small_'+item[i]+'_score'][4]],
					itemStyle : { normal: {label : {show: true},textStyle:{color:e.color.text}}},
					lineStyle : {normal:{width:3}}
				}]
			};
		}else if(item[i] == "reading_rate"){
			var idName = "diy0";
			var name = "阅读正确单词数";
			var opt = {
				title: {
					text: name,
					textStyle:{color:e.color.text,fontSize:16},
				},
				animation: false,
				tooltip: {
					trigger: 'axis'
				},
				legend: {
					data:['个人阅读正确单词数','小营平均'],
					top:"10%",
					textStyle:{color:e.color.text},
				},
				color:e.color.image,
				xAxis: {
					type: 'category',
					boundaryGap: false,
					data:["营前","营后"],
					axisLine: {
						lineStyle: {type: 'solid',color: e.color.axis}
					},
					axisLabel: {
						textStyle: {
							color: e.color.text,fontSize:16}
					}
				},
				yAxis: {
					type: 'value',
					scale:true,
					axisLine: {
						lineStyle: {type: 'solid',color: e.color.axis}
					},
					axisLabel: {
						textStyle: {
							color: e.color.text,fontSize:16}
					},
					splitLine:{
						lineStyle:{color:e.color.split}
					}
				},
				series: [{
					name:'个人阅读正确单词数',
					type:'line',
					data:[e.student["{{$id}}"][item[i]].all[1],e.student["{{$id}}"][item[i]].all[4]],
					itemStyle : { normal: {label : {show: true},textStyle:{color:e.color.text}}},
					lineStyle : {normal:{width:3}}
				},{
					name:'小营平均',
					type:'line',
					data:[e.common['small_'+item[i]+'_score'][1],e.common['small_'+item[i]+'_score'][4]],
					itemStyle : { normal: {label : {show: true},textStyle:{color:e.color.text}}},
					lineStyle : {normal:{width:3}}
				}]
			};
		}else{
			continue;
		}
		if(item[i] != "phonics_rate"){
			echarts.init(document.getElementById(idName)).setOption(opt);
		}
	}

	var zyRateOpt = {
		animation:false,
		legend: {
			textStyle:{
				color:e.color.text
			},
			top:"10%"
		},
		title: {
			text:"作业正常率",
			textStyle:{
				color:e.color.text
			},
		},
		xAxis: {
			type: 'value',
			axisLine: {
				lineStyle: {
					type: 'solid',
					color: e.color.axis,//左边线的颜色
				}
			},
			axisLabel: {
				textStyle: {
					color: e.color.text,//坐标值得具体的颜色
					fontSize:16

				}
			}
		},
		yAxis: {
			type: 'category',
			axisLine: {
				lineStyle: {
					type: 'solid',
					color: e.color.axis,//左边线的颜色
				}
			},
			axisLabel: {
				textStyle: {
					color: e.color.text,//坐标值得具体的颜色
					fontSize:16

				}
			},
			splitLine:{
				lineStyle:{
					color:e.color.split
				}
			}
		},
		color:e.color.image,
		series: [{
			type: 'bar',
			label: {
				normal: {
					show: true,
					position: 'right',
					color:e.color.image_display,
					formatter: '{a}\n{c}',
					fontSize: 16,
				}
			},
			data:[e.student[["{{$id}}"]]['zuoye'].rate],name:'个人'
		},{
			type: 'bar',
			label: {
				normal: {
					show: true,
					position: 'right',
					color:e.color.image_display,
					formatter: '{a}\n{c}',
					fontSize: 16,
					}
				},
			data:[e.common.small_zuoye],name:'小营'
		},
		{
			type: 'bar',
			label: {
				normal: {
					show: true,
					position: 'right',
					color:e.color.image_display,
					formatter: '{a}\n{c}',
					fontSize: 16,
				}
			},
			data:[e.common.big_zuoye],name:'大营'
		}
		]
	};
	// var zyScoreOpt = {
	// 	title: {
	// 		text: "作业分数",
	// 		textStyle:{
	// 			color:e.color.text
	// 		},
	// 	},
	// 	tooltip: {
	// 		trigger: 'axis'
	// 	},
	// 	color:e.color.image,
	// 	legend: {
	// 		data:['个人','小营','大营'],
	// 		textStyle:{
	// 			color:e.color.text
	// 		},
	// 		top:"10%"
	// 	},
	// 	grid: {},
	// 	xAxis: {
	// 		type: 'category',
	// 		boundaryGap: false,
	// 		data:mkXdata(e),
	// 		axisLine: {
	// 			lineStyle: {
	// 				type: 'solid',
	// 				color: e.color.axis,//左边线的颜色
	// 			}
	// 		},
	// 		axisLabel: {
	// 			textStyle: {
	// 				color: e.color.text,//坐标值得具体的颜色
	//
	// 			}
	// 		}
	// 	},
	// 	yAxis: {
	// 		type: 'value',
	// 		scale:true,
	// 		axisLine: {
	// 			lineStyle: {
	// 				type: 'solid',
	// 				color: e.color.axis,//左边线的颜色
	// 			}
	// 		},
	// 		axisLabel: {
	// 			textStyle: {
	// 				color: e.color.text,//坐标值得具体的颜色
	//
	// 			}
	// 		},
	// 		splitLine:{
	// 			lineStyle:{
	// 				color:e.color.split
	// 			}
	// 		}
	// 	},
	// 	series: [
	// 		{
	// 			name:'个人',
	// 			type:'line',
	// 			data:Object.keys(e.student["{{$id}}"]['zuoye'].all).map(function (key) {
	// 				return e.student["{{$id}}"]['zuoye'].all[key];
	// 			}),
	// 			itemStyle : { normal: {label : {show: true},textStyle:{color:e.color.text}}},
	// 			lineStyle : {normal:{width:3}}
	// 		},
	// 		{
	// 			name:'小营',
	// 			type:'line',
	// 			data:Object.keys(e.common.small_zuoye_score).map(function (key) {
	// 				return e.common.small_zuoye_score[key];
	// 			}),
	// 			itemStyle : { normal: {label : {show: true},textStyle:{color:e.color.text}}},
	// 			lineStyle : {normal:{width:3}}
	// 		},
	// 		{
	// 			name:'大营',
	// 			type:'line',
	// 			data:Object.keys(e.common.big_zuoye_score).map(function (key) {
	// 				return e.common.big_zuoye_score[key];
	// 			}),
	// 			itemStyle : { normal: {label : {show: true},textStyle:{color:e.color.text}}},
	// 			lineStyle : {normal:{width:3}}
	// 		}
	// 	]
	// };

	var kqOpt = {
		legend: {
			textStyle:{
				color:e.color.text,
			},
			top:"10%"
		},
		tooltip: {},
		title: {
			text:"考勤全勤率",
			textStyle:{
				color:e.color.text,
			},
		},
		animation: false,
		color:e.color.image,
		xAxis: {
			type: 'value',
			axisLine: {
				lineStyle: {
					type: 'solid',
					color: e.color.axis,//左边线的颜色
				}
			},
			axisLabel: {
				textStyle: {
					color: e.color.text,//坐标值得具体的颜色
					fontSize:16

				}
			}
		},
		yAxis: {
			type: 'category',
			axisLine: {
				lineStyle: {
					type: 'solid',
					color: e.color.axis,//左边线的颜色
				}
			},
			axisLabel: {
				textStyle: {
					color: e.color.text,//坐标值得具体的颜色
					fontSize:16

				}
			},
			splitLine:{
				lineStyle:{
					color:e.color.split
				}
			}
		},
		series: [{
			type: 'bar',
			label: {
				normal: {
					show: true,
					position: 'right',
					color:e.color.image_display,
					formatter: '{a}\n{c}',
					fontSize: 16,
				}
			},
			data:[e.student['{{$id}}']['kaoqin'].rate],name:'个人'
		},{
			type: 'bar',label: {
				normal: {
					show: true,
					position: 'right',
					color:e.color.image_display,
					formatter: '{a}\n{c}',
					fontSize: 16,
				}
			},
			data:[e.common.small_kaoqin],name:'小营'
		},{
			type: 'bar',label: {
				normal: {
					show: true,
					position: 'right',
					color:e.color.image_display,
					formatter: '{a}\n{c}',
					fontSize: 16,
				}
			},
			data:[e.common.big_kaoqin],name:'大营'
		}]
	};
	// var radarOpt = {
	// 	color:e.color.image,
	//     title: {
	//         text: '雷达图',
 //            subtext: 'A.15s字母音识别数\nB.1min拼读单词数 C.每分钟阅读正确词数WCPM',
	// 		subtextStyle:{
	// 			align:"center"
	// 		}
	//     },
	// 	animation: false,
	//     legend: {
	//         data: ['个人','小营'],
	// 		top:"0",right:"0"
	//     },
	//     radar: {
	// 		radius:"80%",
	// 		center:["50%","65%"],
	// 		scale:true,
	// 		nameGap:0,
	//         name: {
	//             textStyle: {
	//                 color: '#000',
	//             }
	//         },
	//         indicator: [
	//            { name: 'A', max:120},
	//            { name: 'B', max:30},
	//            { name: 'C', max:30},
	//         ]
	//     },
	//     series: [{
	//         type: 'radar',
	// 		label:{
	// 			show:true
	// 		},
	//         data : [{
	// 			name : '个人',
	// 			areaStyle:{
	// 				color:"#FFF000"
	// 			},
	// 			value : [
	// 				e.student['{{$id}}'].reading_rate.avg,
	// 				e.student['{{$id}}'].letter_rate.avg,
	// 				e.student['{{$id}}'].phonics_rate.avg
	// 			]
	// 		},{
	// 			name : '小营',
	// 			value : [
	// 				e.common.small_reading_rate_avg,
	// 				e.common.small_letter_rate_avg,
	// 				e.common.small_phonics_rate_avg,
	// 			]
 //            },/*{
	// 			name : '大营',
	// 			value : [
	// 				e.common.big_reading_speed_avg,
	// 				e.common.big_reading_rate_avg,
	// 				e.common.big_phonics_rate_avg,
	// 			]
 //            }*/]
	//     }]
	// };

	var zyRateChart = echarts.init(document.getElementById("zy-chart0"));
	// var zyScoreChart = echarts.init(document.getElementById("zy-chart1"));
	var kqChart = echarts.init(document.getElementById("kq-chart"));
	// var radarChart = echarts.init(document.getElementById("radar"));

	zyRateChart.setOption(zyRateOpt);
	// zyScoreChart.setOption(zyScoreOpt);
	kqChart.setOption(kqOpt);
	// radarChart.setOption(radarOpt);
}


function mkDiyXData(e,item){
	let obj = e.common["big_"+item+"_score"];
	let data = [];
	for(d=1;d<=Object.keys(obj).length;d++){
		if (d==1) {
		data.push('营前');
		}else{
		data.push('第'+(d-1)+'次');
		}
	}
	return data;
}

function fillText(res) {
	st = res.student["{{$id}}"];
	$("#diy0-text").html(st.reading_rate.score_memo + st.reading_rate.rate_memo);
	// $("#diy1-text").html(st.letter_rate.score_memo + st.letter_rate.rate_memo);
	// $("#diy2-text").html(st.phonics_rate.score_memo + st.phonics_rate.rate_memo);
	// $("#kq-text").html(st.kaoqin.rate_memo);
	// $("#zy-text").html(st.zuoye.rate_memo);
	$("#ch_name").html(st.ch_name)
	$("#en_name").html(st.en_name)
	$(".camp_sn").html(res.camp_name)
	$("#tutor_name").html(res.tutor)

	// $("#radar-border").html('黄色线就是个人能力评价，蓝色线是班级平均水品\n' +
 //        'A-15s字母音识别数：15s之内自然拼读字母音识别数量\n' +
 //        'B-1min拼读单词数：指1分钟内能读一篇文章的多少个单词\n' +
 //        'C-每分钟阅读正确词数WCPM：指1分钟阅读的总词数中正确词数有多少'
	// );
	if(res.memo.length > 0){
		// $("#diy0-border").html(decodeURI(res.memo[1]));
		// $("#diy1-border").html(decodeURI(res.memo[2]));
		// $("#diy2-border").html(decodeURI(res.memo[3]));
		// $("#kq-border").html(decodeURI(res.memo[4]));
		// $("#zy-border").html(decodeURI(res.memo[1]));
	}
}

function save_memo(){
	var url = window.location.href;
	pid = url.split('=')[2];

	let memoArr = [
		// emoji_encode($("#radar-border").val()),
		// emoji_encode($("#diy0-border").val()),
		// emoji_encode($("#diy1-border").val()),
		// emoji_encode($("#diy2-border").val()),
		emoji_encode($("#kq-border").val()),
		// emoji_encode($("#zy-border").val()),
	];
	let param = {
		_token:"{{csrf_token()}}",
		pid:pid,
		memo:JSON.stringify(memoArr)
	}
	$.post('/admin/kly_report/save_memo',param,function(e){
		alert('操作成功');
	})
}

function o_window(isprint){
	if(isprint){
		alert("请将变距设置为0,勾选背景图层，取消勾选页眉页脚，将缩放设置为100，纸张选择A4");
	}
	var wi = window.open('about:blank', '_blank');

	wi.document.write(document.getElementById('chart_container').outerHTML);

	var listnew = wi.document.getElementsByTagName("canvas");
	var listold = document.getElementsByTagName("canvas");
	for(i=0;i<listold.length;i++){
		var ctx = listold[i].getContext('2d');
		var imgdata = ctx.getImageData(0,0,2500,7500
		);
		var ctxnew = listnew[i].getContext('2d');
		ctxnew.putImageData(imgdata,0,0);
	}
	var oDiv = wi.document.getElementById("chart_container");

	if(isprint){
		wi.document.querySelector("body").style.margin = 0;
		wi.print();
	}else{
		wi.opener.export_pdf(oDiv);
		setTimeout(function(){
			wi.close();
		},1000);
	}
}

function export_pdf(oDiv){
	var contentWidth = 0;
	var contentHeight = 0;
	var w = parseInt(window.getComputedStyle(oDiv).width);
	var h = parseInt(window.getComputedStyle(oDiv).height);
	var canvas1 = document.createElement("canvas");

	html2canvas(oDiv, {canvas:canvas1,width:oDiv.offsetWidth,height:oDiv.offsetHeight,logging:false,scale:1}).then(function(canvas) {
		contentWidth = canvas.width;
		contentHeight = canvas.height;
		//一页pdf显示html页面生成的canvas高度;
		var pageHeight = contentWidth / 595.28 * 841.89;
		//未生成pdf的html页面高度
		var leftHeight = contentHeight;
		//页面偏移
		var position = 0;
		//a4纸的尺寸[595.28,841.89]，html页面生成的canvas在pdf中图片的宽高
		var imgWidth = 595.28;
		var imgHeight = 595.825 / contentWidth * contentHeight;
		//canvas.getContext("2d").translate(-500,-20);
		var pageData = canvas.toDataURL('image/jpeg', 0.95);
		//console.log(pageData);
		//注①
		var pdf = new jsPDF('', 'pt', 'a4');
		//有两个高度需要区分，一个是html页面的实际高度，和生成pdf的页面高度(841.89)
		//当内容未超过pdf一页显示的范围，无需分页
		if (leftHeight < pageHeight) {
			pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);
		} else {
			while (leftHeight > 0) {
				//arg3-->距离左边距;arg4-->距离上边距;arg5-->宽度;arg6-->高度
				pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
				leftHeight -= pageHeight;
				position -= 841.89;
				//避免添加空白页
				if (leftHeight > 100) {
					//注②
					pdf.addPage();
				}
			}
		}

		pdf.save(stFullName+'.pdf');
	});
}

function emoji_encode(str){
	if(str){
		return encodeURI(str);
	}else{
		return "";
	}
}


function data_person(e){
	// "phonics_rate" "letter_rate"
	// [e.student["{{$id}}"][item[i]].all[1],e.student["{{$id}}"][item[i]].all[4]],
	var data = [];
	data.push(((e.student["{{$id}}"]['letter_rate'].all[1]*1.5 + e.student["{{$id}}"]['phonics_rate'].all[1]*2)/80*100).toFixed(2));
	data.push(((e.student["{{$id}}"]['letter_rate'].all[4]*1.5 + e.student["{{$id}}"]['phonics_rate'].all[4]*2)/80*100).toFixed(2));
	return data;
}

function data_sm_camp(e){
	//[e.common['small_'+item[i]+'_score'][1],e.common['small_'+item[i]+'_score'][4]],
	var data = [];
	data.push(((e.common['small_letter_rate_score'][1]*1.5 + e.common['small_phonics_rate_score'][1]*2)/80 * 100).toFixed(2));
	data.push(((e.common['small_letter_rate_score'][4]*1.5 + e.common['small_phonics_rate_score'][4]*2)/80 * 100).toFixed(2));
	return data;
}
</script>
